package cn.ithers.blog.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
 * @Author: zhanghuan
 * @date: 2020/10/26 10:17
 * @description:
 */
@Slf4j
@Configuration
@Order(Ordered.HIGHEST_PRECEDENCE)
public class StartedListener implements ApplicationListener<ApplicationStartedEvent> {

    @Value("${blog-url}")
    private String url;

    @Value("${server.port}")
    private String port;

    @Override
    public void onApplicationEvent(ApplicationStartedEvent applicationStartedEvent) {

        this.printStartInfo();
    }

    private void printStartInfo() {

        log.info("Blog started at         {}", url + ":" + port);
        log.info("Blog has started successfully!");
    }

}
